var aaa = "我是一名优秀的社会主义接班人";
var bbb = "我***一名***的***会主义***";
console.log(bbb);

let b_i = 0; //0 1 4 5 6 9
let bj = 0;
let word = "";
let words = [];
console.log(word, words);

// for (let i = 0; i < aaa.length; i++) {
//   if (aaa[i] != bbb[b_i] && bj == 0) {
//     b_i += 3;
//     bj = 1;
//     word = "";
//     word += aaa[i];
//   } else if (aaa[i] != bbb[b_i] && bj == 1) {
//     word += aaa[i];
//   } else if (aaa[i] == bbb[b_i] && bj == 1) {
//     bj = 0;
//     b_i += 1;
//     words.push(word);
//   } else {
//     b_i += 1;
//   }
// }

for (let i = 0; i < aaa.length; i++) {
  if (aaa[i] != bbb[b_i]) {
    if (bj == 0) {
      b_i += 3;
      bj = 1;
      word = "";
    }
    word += aaa[i];
  } else if (aaa[i] == bbb[b_i]) {
    if (bj == 1) {
      bj = 0;
      words.push(word);
    }
    b_i += 1;
  }
}

word ? words.push(word) : "";

console.log("还剩一个值", word);

console.log("最后", words);
